<template>
  <div>
    <el-dialog
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      title="会员绑定二维码"
      width="600px"
      @close="close"
    >
      <div class="textC">将此二维码发送给已导入数据的会员, 即可扫码进行绑定。</div>
      <div v-loading="loading" class="qr-code">
        <img :src="qrCodeUrl" alt>
        <!-- <img src="../../../../static/img/default.jpg" alt> -->
      </div>
      <!-- <div slot="footer" class="dialog-footer">
        <el-button size="small" round @click="hide">取 消</el-button>
        <el-button size="small" round type="primary" @click="handleSubmit()">确 定</el-button>
      </div>-->
    </el-dialog>
  </div>
</template>

<script>
import { getImportVipBindQrCode } from '@/api/vip'
export default {
  data() {
    return {
      // 配置
      resolve: null,
      reject: null,
      //  状态
      dialogVisible: null,
      loading: false,
      // 数据
      data: '',
      qrCodeUrl: ''
    }
  },
  methods: {
    /**
       * 获取数据
       */
    // 获取二维码
    initData() {
      this.loading = true
      getImportVipBindQrCode({
        appId: this.$store.state.wechat.maInfo.DEFAULT.appId
      })
        .then(res => {
          this.loading = false
          this.qrCodeUrl = res.data
        })
        .catch(err => {
          this.loading = false
        })
    },

    open() {
      this.show()
      return new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
    },

    show() {
      this.initData()
      this.dialogVisible = true
    },

    close() {
      this.loading = false
    },

    hide() {
      this.resolve = null
      this.reject = null
      this.dialogVisible = false
    },
    handleSubmit() {}
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .qr-code {
    margin: 20px auto;
    width: 300px;
    height: 300px;
  }
</style>
